<?php
/**
 * Created by PhpStorm.
 * User: lx
 * Date: 2020/1/7
 * Time: 10:15
 */
namespace app\hook\behavior;

use think\Hook;
use think\App;

class errorLog
{
    public function run(\Request $request, $param){
        if(!$this->errLog($param)){}
    }

    /**
     * 错误日志
     * @param $param
     */
    public function errLog($param){
        $errLogPath = config("apiadmin.ERR_LOG_PATH");
        $errFilePath = $errLogPath."err".date("Ymd").".txt";
        if(!file_exists($errFilePath)){
            fopen($errFilePath, "w");
            chmod($errFilePath,"0777");
        }
        file_put_contents($errFilePath, date("Y-m-d His").$_SERVER['REQUEST_URI'].'----'.$param.PHP_EOL, FILE_APPEND);
    }
}
